package com.demo.controller;


import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/student")
public class StudentController {

    @RequestMapping("/hello")
    public String auth(){
        return "Hello World!";
    }

    @RequestMapping("/auth")
    public Object auth(Authentication authentication){
        return authentication;
    }

    @RequestMapping("/auth2")
    public Object auth2(Authentication authentication){
        OAuth2Authentication auth2Authentication = (OAuth2Authentication)authentication;
        Authentication userAuthentication = auth2Authentication.getUserAuthentication();
        return userAuthentication;
    }


    @RequestMapping("/auth3")
    public Object auth3(Authentication authentication){
        Object principal = authentication.getPrincipal();
        return principal;
    }

}
